/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colloque.servlets;

import colloque.Colloque;
import colloque.Expose;
import colloque.forms.ExposeForm;
import colloque.helpers.ColloqueHelper;
import colloque.helpers.InstitutionHelper;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Thomas
 */
public class CreerExposeAnonyme extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        int Colid = Integer.parseInt(request.getParameter("colloqueid"));
        try {
            ColloqueHelper colloquehelper = new ColloqueHelper();
            InstitutionHelper institutionhelper = new InstitutionHelper();
            Colloque colloque = (Colloque) colloquehelper.getColloqueById(Colid);
            request.setAttribute("colloque", colloque);
            List institutions = institutionhelper.getallinstitution();
            request.setAttribute("institutions", institutions);
        } catch (Exception e) {
            e.printStackTrace();
        }

        RequestDispatcher distpacher = request.getRequestDispatcher("/jsp/CreerExposeAnonyme.jsp");
        distpacher.forward(request, response);
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            ExposeForm exposeform = new ExposeForm();
            Expose oexpo = exposeform.creerExposeAnonyme(request);
            request.setAttribute("oexpo", oexpo);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            this.getServletContext().getRequestDispatcher("/jsp/CreerColloqueSuccess.jsp").forward(request, response);
        }
    }
}
